package com.xing.service.impl;

import com.xing.dao.SystemFunctionMapper;
import com.xing.entity.pojo.SystemFunction;
import com.xing.entity.vo.AuthorityUser;
import com.xing.service.SystemFunctionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemFunctionServiceImpl implements SystemFunctionService {
    @Autowired
    private SystemFunctionMapper systemFunctionMapper;
    @Override
    public int deleteByPrimaryKey(String funId) {
        return systemFunctionMapper.deleteByPrimaryKey(funId);
    }

    @Override
    public int insert(SystemFunction record) {
        return systemFunctionMapper.insert(record);
    }

    @Override
    public int insertSelective(SystemFunction record) {
        return systemFunctionMapper.insertSelective(record);
    }

    @Override
    public SystemFunction selectByPrimaryKey(String funId) {
        return systemFunctionMapper.selectByPrimaryKey(funId);
    }

    @Override
    public int updateByPrimaryKeySelective(SystemFunction record) {
        return systemFunctionMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(SystemFunction record) {
        return systemFunctionMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<AuthorityUser> findByRoleID(String roleID) {
        return systemFunctionMapper.findByRoleID(roleID);
    }

    @Override
    public List<AuthorityUser> findFunAll() {
        return systemFunctionMapper.findFunAll();
    }

    @Override
    public List<SystemFunction> findSonAll() {
        return systemFunctionMapper.findSonAll();
    }

    @Override
    public Boolean deletePrFunction(String[] ids) {
        boolean flag=false;
        for (int i = 0; i <ids.length ; i++) {
            int i1 = systemFunctionMapper.deleteByPrimaryKey(ids[i]);
            if(i1>0){
                flag=true;
            }else {
                flag=false;
            }
        }
        return flag;
    }
}
